package com.guo.redis.config.lock;

public class LockValueContainer {
    private static final ThreadLocal<String> threadLocalContainer = new ThreadLocal<>();
    private static volatile LockValueContainer instance = null;
    private LockValueContainer() {
    }

    public void saveValue(String value){
        threadLocalContainer.set(value);
    }

    public String getValue(){
        return threadLocalContainer.get();
    }


    public void remove(){
        threadLocalContainer.remove();
    }

    public static LockValueContainer getInstance(){
        if(instance == null){
            synchronized (LockValueContainer.class){
                if( instance == null){
                    instance = new LockValueContainer();
                }
            }
        }
        return instance;
    }
}
